[FIXED] MyBatis where in Enum ~ JavaFixing | 您所在的位置:网站首页 › idea mybatis log › [FIXED] MyBatis where in Enum ~ JavaFixing |
[FIXED] MyBatis where in Enum
September 24, 2022 enums, java, mybatis, spring-boot IssueI'm using Java spring and MyBatis. I have an Enum like this public enum MyEnum { A,B,C,D,E }now I want to write a query and in my query I want to have this : SELECT * FROM table where myColumn in ("A", "B", "C", "D", "E")How can I achieve this? I tried converting it to array of strings in my java code and pass it as parameter to my query, and I created this query : #{item}and I receive following error : Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: The column index is out of range: 11, number of columns: 10.\"BTW, I'm using xml files for my queries. I've checked this answer : Mybatis foreach iteration over list of integers within a complex object parameter which appears to work for list of integers but apparently not for list of strings or enums. SolutionFirst comment solved my issue, so I should replace this: #{item}with this: #{item}Answered By - Majid Abdolhosseini Answer Checked By - Marie Seifert (JavaFixing Admin) Share This: Facebook Twitter Google+ Stumble Digg This Answer collected from stackoverflow and tested by JavaFixing community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 |
CopyRight 2018-2019 实验室设备网 版权所有 |